package com.zang.blogz.enmus;

import cn.hutool.core.util.StrUtil;
import io.github.vampireachao.stream.core.optional.Opp;
import io.github.vampireachao.stream.core.stream.Steam;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.function.Predicate;

/**
 * @Author: ZVerify
 * @Description:  上传策略枚举类
 * @DateTime: 2022/8/31 17:20
 **/

@Getter
@AllArgsConstructor
public enum UploadStrategyEnum {

    /**
     * oss
     */
    OSS("oss", "ossUploadStrategyImpl"),
    /**
     * 本地
     */
    LOCAL("local", "localUploadStrategyImpl");


    /**
     * 模式
     */
    private final String mode;

    /**
     * 策略
     */
    private final String strategy;

    /**
     * 获取策略
     * @param mode 模式
     * @return {@link String} 搜索策略
     */
    public static String getStrategy(String mode){

        return Steam.of(UploadStrategyEnum.values()).findFirst(strategy(mode)).orElse(OSS).getStrategy();

    }

    public static Predicate<? super UploadStrategyEnum> strategy(String mode){

        return val->  StrUtil.equals(val.getMode(), mode);
    }


}
